$().ready(function() {
	$('#login_form').validate({
	    rules: { 
	    	mobilePhone: {
	        required:true,
	        isMobile:true,
	        remote: {
	               url: "checkMobilePhone",
	               type: "post",
	               dataType: "json",
	               data: {
	            	   mobilePhone: function () {
	                       return $("#mobilePhone").val();
	                   }
	               },
	               dataFilter: function (data) {
	                   if (data == "true") {
	                       return true;
	                   }
	                   else {
	                       return false;
	                   }
	               }
	           }
	        },
	        password:{
	        	required:true,
	        	rangelength:[6,20],
	        	remote: {
		               url: "checkPassword",
		               type: "post",
		               dataType: "json",
		               data: {
		            	   password_str: function () {
		            		   $.base64.utf8encode = true;
		                   	   var str = $("#mobilePhone").val()+":"+$('#password').val();
		                   	   var password_str = $.base64('encode', str);
		                       return password_str;
		                   }
		               },
		               dataFilter: function (data) {
		                   if (data == "true") {
		                       return true;
		                   }
		                   else {
		                       return false;
		                   }
		               }
		           }
	        }
	    },
	    messages: {
	    	mobilePhone: {
		        isMobile: "请输入一个正确的手机号码",
		        remote: "该号码未注册，请先注册"
		      },
		    password:{
		    	remote: "请输入正确的密码"
			 }
	    }
	});
});

$(function(){
	/*绑定提交按钮事件*/
	$('#login_submit').on('click', function(){
		$.base64.utf8encode = true;
		var str = $("#mobilePhone").val()+":"+$('#password').val();
		var login_str = $.base64('encode', str);
		var $login_str = $('#login_str');
		$login_str.val(login_str);
	});
})